package ces.lawsuit.validator;


import com.jfinal.core.Controller;
import com.jfinal.kit.JsonKit;
import com.jfinal.kit.StrKit;
import com.jfinal.validate.Validator;

import ces.lawsuit.model.Result;
import ces.lawsuit.model.Valid;

public abstract class BaseValidator extends Validator {
	
	//Controller  controller=super.getController();
    Valid valid=new Valid(true,"验证通过!");
	Result result=new Result();
	@Override
	protected void handleError(Controller c) {
		 c.renderJson(JsonKit.toJson(valid));
	}

	protected boolean validateRequired(String field,String errorMsg){
		if(StrKit.isBlank(getController().getPara(field))){
			   valid.setStatus(false);
			   valid.setMsg(errorMsg);
			   return false;
		   }
		return true;
	}

   
}
